local tianli_active = fk.CreateSkill {
  name = "kq__tianli_active&",
}

Fk:loadTranslationTable{
    ["kq__tianli_active&"] = "天立",
    [":kq__tianli_active&"] = "出牌阶段开始时，你可以重铸或交给 姜维（主公） 一张【杀】",
    ["#ask__shooose"] = "交给 %src 一张【杀】"
}

tianli_active:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  prompt = "你可以重铸或交给 姜维（主公） 一张【杀】",
  can_trigger = function(self, event, target, player, data)
    if player.phase == player.Play and player.kingdom == "qun" then
      return table.find(Fk:currentRoom().alive_players, function(p) return p:hasSkill("kq__tianli") and p ~= player end)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function(p)
      return p:hasSkill("kq__tianli") and p ~= player
    end)[1]
    local choice = room:askToChoice(player, {
        choices = {"重铸一张【杀】" , "#ask__shooose:"..targets.id , "Cancel"},
        skill_name = tianli_active.name
      })
      if choice == "重铸一张【杀】" then
        local cards = room:askToCards(player, {
            min_num = 1,
            max_num = 1,
            skill_name = tianli_active.name,
            pattern = "slash",
            prompt = "请选择一张【杀】",
            cancelable = true,
        })
        room:recastCard(cards, player, tianli_active.name)
      elseif choice == "#ask__shooose:"..targets.id then
        local cards = room:askToCards(player, {
            min_num = 1,
            max_num = 1,
            skill_name = tianli_active.name,
            pattern = "slash",
            prompt = "请选择一张【杀】",
            cancelable = true,
        })
        room:obtainCard(targets, cards, false, fk.ReasonGive)
      end
  end,
})

return tianli_active